android.ndk.looper

@file looper.h

Members

Aliases

ALooper_callbackFunc
alias ALooper_callbackFunc = int function(int fd, int events, void* data)

For callback-based event loops, this is the prototype of the function that is called when a file descriptor event occurs. It is given the file descriptor it is associated with, a bitmask of the poll events that were triggered (typically ALOOPER_EVENT_INPUT), and the data pointer that was originally supplied.

Enums

ALOOPER_EVENT_INPUT
enum ALOOPER_EVENT_INPUT

Flags for file descriptor events that a looper can monitor.

ALOOPER_POLL_WAKE
enum ALOOPER_POLL_WAKE

Result from ALooper_pollOnce() and ALooper_pollAll().

ALOOPER_PREPARE_ALLOW_NON_CALLBACKS
enum ALOOPER_PREPARE_ALLOW_NON_CALLBACKS

Option for for ALooper_prepare().

Functions

ALooper_acquire
void ALooper_acquire(ALooper* looper)

Acquire a reference on the given ALooper object. This prevents the object from being deleted until the reference is removed. This is only needed to safely hand an ALooper from one thread to another.

ALooper_addFd
int ALooper_addFd(ALooper* looper, int fd, int ident, int events, ALooper_callbackFunc callback, void* data)

Adds a new file descriptor to be polled by the looper. If the same file descriptor was previously added, it is replaced.

ALooper_forThread
ALooper* ALooper_forThread()

Returns the looper associated with the calling thread, or NULL if there is not one.

ALooper_pollAll
int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData)

Like ALooper_pollOnce(), but performs all pending callbacks until all data has been consumed or a file descriptor is available with no callback. This function will never return ALOOPER_POLL_CALLBACK.

ALooper_pollOnce
int ALooper_pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData)

Waits for events to be available, with optional timeout in milliseconds. Invokes callbacks for all file descriptors on which an event occurred.

ALooper_prepare
ALooper* ALooper_prepare(int opts)

Prepares a looper associated with the calling thread, and returns it. If the thread already has a looper, it is returned. Otherwise, a new one is created, associated with the thread, and returned.

ALooper_release
void ALooper_release(ALooper* looper)

Remove a reference that was previously acquired with ALooper_acquire().

ALooper_removeFd
int ALooper_removeFd(ALooper* looper, int fd)

Removes a previously added file descriptor from the looper.

ALooper_wake
void ALooper_wake(ALooper* looper)

Wakes the poll asynchronously.

Meta